<template>
  <el-container id="iUser">
    <div class="image" @click="toUser"></div>
    <div class="info" @click="toUser">
      <div class="name">{{ $store.state.userinfo.name }}</div>
      <div class="phone">{{ $store.state.userinfo.phone }}</div>
      <div class="email">{{ $store.state.userinfo.email }}</div>
    </div>
  </el-container>
</template>

<script>
import * as auth from '../utils/auth'
import * as api from '../api/public/iUser'
export default {
  name: 'iUser',
  methods: {
    async getUserInfo() {
      const data = await api.getUserInfo({ id: auth.getUserId() })
      if (data.code === 0) {
        this.$store.commit('setUserInfo', data.data)
      }
    },
    toUser() {
      this.$router.push({ name: 'Userinfo' })
    }
  },
  created() {
    this.getUserInfo()
  }
}
</script>

<style lang="scss" scoped>
#iUser {
  width: 100%;
  height: 10rem;
  background: white;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;

  .image {
    width: 30%;
    box-sizing: border-box;
    display: flex;
    align-content: center;
    flex-flow: row wrap;
  }

  .info {
    width: 70%;
    box-sizing: border-box;
    padding: 0.5rem;
    display: flex;
    align-content: center;
    flex-flow: row wrap;

    & > div {
      width: 100%;
      line-height: 1.75;
    }

    .name {
      font-size: 1.2rem;
      font-weight: bold;
    }
  }
}
</style>
